home *** CD-ROM | disk | FTP | other *** search
- /*
- ** Program: BTNC
- **
- ** Module: Nodelist line parser
- */
-
- #include <portab.h>
-
- #include <stdlib.h>
- #include <string.h>
-
- #include "general.h"
- #include "globals.h"
- #include "prototyp.h"
- #include "logfile.h"
-
- UWORD last_node; /* OB */
-
- WORD ParseLine(WORD type, BYTE *NLline, INDEX *idx, SYSTEM *sys, UWORD nl_lines)
- {
- BYTE line[1024],
- *nextstart,
- attr[100],
- valstr[100],
- field[100],
- namebuf[100],
- namebuf2[100],
- hostname[34],
- *name1,
- *name2;
- WORD val;
-
- CleanString(NLline, line);
-
- nextstart = NextField(line, attr);
- nextstart = NextField(nextstart, valstr);
- val = atoi(valstr);
-
- idx->value = val;
-
- if ((idx->type = type) == NODE)
- {
- curaddr.node = val;
- curaddr.point = 0;
- }
- else
- curaddr.point = val;
-
- if (*attr)
- {
- if (*attr == 'H' && attr[2] == 's')
- {
- idx->type = HOST;
- curaddr.net = val;
- curaddr.node = curaddr.point = curhub = 0;
- }
- else
- if (*attr == 'H' && attr[1] == 'u')
- {
- idx->type = HUB;
- curhub = val;
- }
- else
- if (*attr == 'D') return(DOWN);
- else
- if (*attr == 'R')
- {
- if (doing_addlist) return(SKIP);
-
- idx->type = RC;
-
- /*
- ** remember last region number;
- */
-
- curaddr.net = curreg = val;
- curaddr.node = curaddr.point = curhub = 0;
- regions++;
- }
- else
- if (*attr == 'P')
- {
- sys->flags |= PRIVATE;
- private_nodes++;
-
- /* Modified : -------------------- */
- if( ADDLIST4D==TRUE)
- {
- idx->type = POINT;
- curaddr.node=last_node;
- curaddr.point = val;
- }
- /* ------------------------------- */
-
- }
- else
- if (*attr == 'H' && attr[2] == 'l')
- sys->flags |= HOLD;
- else
- if (*attr == 'Z')
- {
- if (doing_addlist) return(SKIP);
-
- idx->type = ZC;
- curaddr.zone = curreg = curaddr.net = val;
- curaddr.node = curaddr.point = curhub = 0;
-
- if (curaddr.zone == onlyzone)
- oz_compiled = TRUE;
- if (display && az_compiled)
- ALL_puts("");
- }
- }
-
- /* Modified OB ---------------------*/
-
- else if (ADDLIST4D==TRUE) /* ',' seems to be a NODE */
- {
- last_node=val;
- }
-
- /* ---------------------------------*/
- if (onlyzone && oz_compiled && curaddr.zone != onlyzone)
- {
- active_nodes--;
- oz_compiled = FALSE;
-
- return(ABORT);
- }
-
- if (onlyzone && curaddr.zone != onlyzone) return(SKIP);
-
- if (*attr == 'Z') zones++;
-
- if (nextstart)
- {
- nextstart = NextField(nextstart, field);
- ReplaceUnderscores(field);
- strncpy(sys->sysname, field, 33L);
-
- /*
- ** Take hostname into memory (for compiling a userlist of the
- ** new german points24 format)
- */
-
- if (idx->type == HOST) strncpy(hostname, sys->sysname, 33L);
-
- /* Modified -------------------- */
-
- else if(ADDLIST4D==TRUE && idx->type == NODE)
- strncpy(hostname, sys->sysname, 33L);
-
- /* ----------------------------- */
-
- }
- else
- {
- ERR_printf ("\nLine %u: Missing system name\n", nl_lines);
- return (ABORT);
- }
-
- if (nextstart)
- {
- nextstart = NextField(nextstart, field);
- ReplaceUnderscores(field);
- strncpy(sys->location, field, 29L);
- }
- else
- {
- ERR_printf("\nLine %u: Missing location\n", nl_lines);
- return (ABORT);
- }
-
-
- if (nextstart)
- {
- nextstart = NextField(nextstart, field);
- ReplaceUnderscores(field);
- strncpy(sys->operator, field, 29L);
- }
- else
- {
- ERR_printf ("\nLine %u: Missing operator name\n", nl_lines);
- return (ABORT);
- }
-
- if (nextstart)
- {
- nextstart = NextField(nextstart, field);
- strncpy (sys->phone, field, 39L);
-
- /* Modified OB ---------------------*/
-
- /*
- if (idx->type == ZC || idx->type == RC || idx->type == HOST || idx->type == HUB)
- strcpy(hubphone, sys->phone);
-
- if ((sys->flags & PRIVATE) && *hubphone)
- strcpy(sys->phone, hubphone);
- }
- */
-
- if ( !(sys->flags & PRIVATE ) )
- if ( stricmp(sys->phone,"-Unpublished-") !=0 )
- strcpy(hubphone, sys->phone);
-
- if ((sys->flags & PRIVATE) && *hubphone)
- {
- if ( stricmp(sys->phone,"-Unpublished-") ==0 )
- strcpy(sys->phone, hubphone);
- }
- }
-
- /* ----------------------------------*/
-
- else
- {
- ERR_printf ("\nLine %u: Missing phone number\n", nl_lines);
- return (ABORT);
- }
-
- if (nextstart)
- {
- nextstart = NextField(nextstart, valstr);
- sys->maxbaud = atoi(valstr)/300;
- }
- else
- {
- ERR_printf ("\nLine %u: Missing baudrate\n", nl_lines);
- return (ABORT);
- }
-
- sys->hubnode = curhub;
-
- if (userlist)
- {
- strcpy(namebuf, sys->operator);
- name1 = strtok(namebuf, " ");
- /* Modified --------------------- */
- /* name2 = strtok(NULL, " "); */
- name2 = strtok(NULL, "");
- /* ------------------------------ */
-
- if (name2)
- {
- strcpy(namebuf2, name2);
- strcat(namebuf2, ", ");
- strcat(namebuf2, name1);
- }
- else
- {
- if (name1)
- strcpy(namebuf2, name1);
- else
- strcpy(namebuf2, "-Unknown-");
- }
-
- /* Modified -------------------- */
- /* Rajoute les points 4d dans la fidouser.lst */
-
- if (ADDLIST4D==TRUE && idx->type == POINT) doing_addlist=FALSE;
-
- /* ----------------------------- */
-
- if (doing_addlist)
- {
- if (points24)
- /*
- fprintf(fidouser_lst, "%s %u:%s\n", namebuf2,
- curaddr.zone, sys->sysname);
- */
-
- /*
- ** New format of Points24
- */
-
- if (curaddr.node)
- {
- fprintf(fidouser_lst, "%s %u:%s.%u\n", namebuf2,curaddr.zone, hostname, curaddr.node);
- }
- }
- else
- {
- if (curaddr.point == 0)
- {
- fprintf(fidouser_lst, "%s %u:%u/%u\n", namebuf2,curaddr.zone, curaddr.net, curaddr.node);
- }
- else
- {
- fprintf(fidouser_lst, "%s %u:%u/%u.%u\n", namebuf2,curaddr.zone, curaddr.net, curaddr.node, curaddr.point);
- }
- }
- }
-
- while (nextstart && *nextstart)
- {
- nextstart = NextField(nextstart, field);
-
- if (*field != 'X' && *field != 'U' && *field != 'I')
- {
- if (*field == 'C' && field[1] == 'M')
- sys->flags |= CM;
- else
- if (*field == 'H')
- {
- if (field[1] == '1' && field[2] == '4')
- sys->modemtype |= HST;
- else
- if (field[1] == '1' && field[2] == '6')
- sys->modemtype |= H16;
- }
- else
- if (*field == 'Z')
- {
- if (field[1] == '1' && field[2] == '9')
- sys->modemtype |= Z19;
- else
- sys->modemtype |= ZYX;
- }
- else
- if (*field == 'M' && field[1] == 'N' && field[2] == 'P')
- sys->modemtype |= MNP;
- else
- {
- if (*field == 'M' && field[1] == 'O')
- sys->flags |= MAILONLY;
- else
- if (*field == 'V')
- if (field[2] == '2')
- {
- if (field[1] == '3')
- {
- if (field[3] == 'B')
- sys->modemtype |= V32B;
- else
- if (field[3] == 'T')
- sys->modemtype |= V32T;
- }
- else
- if (field[1] == '4')
- {
- if (field[3] == 'B')
- sys->modemtype |= V42B;
- sys->modemtype |= V42;
- }
- }
- else
- {
- if (field[2] == '4' && field[1] == '3')
- sys->modemtype |= V34;
- else
- {
- if (field[2] == 'C' && field[1] == 'F')
- sys->modemtype |= V34;
- else
- if (field[2] == '1')
- {
- if (field[4] == 'L')
- sys->modemtype |= ISDNA;
- else
- sys->modemtype |= ISDNB;
- }
-
- }
- }
- else
- {
- if (*field == 'M' && field[1] == 'A' && field[2] == 'X')
- sys->modemtype |= MAX;
- else
- if (*field == 'M' && field[1] == 'N')
- sys->flags |= NOARCMAIL;
- }
- }
- }
- else
- {
- if (*field == 'X')
- {
- switch (field[1])
- {
- case 'A':
- sys->flags |= BARKREQ;
- sys->flags |= BARKUPDREQ;
- sys->flags |= WAZOOREQ;
- sys->flags |= WAZOOUPDREQ; break;
- case 'B':
- sys->flags |= BARKREQ;
- sys->flags |= BARKUPDREQ;
- sys->flags |= WAZOOREQ; break;
- case 'P':
- sys->flags |= BARKREQ;
- sys->flags |= BARKUPDREQ; break;
- case 'R':
- sys->flags |= BARKREQ;
- sys->flags |= WAZOOREQ; break;
- case 'W':
- sys->flags |= WAZOOREQ; break;
- case 'X':
- sys->flags |= WAZOOREQ;
- sys->flags |= WAZOOUPDREQ; break;
- case '7':
- sys->modemtype |= ISDNC;
- }
- }
- else
- {
- if (*field == 'U')
- {
- if (field[1] == 'I' && field[2] == 'S' && field[3] == 'D' && field[4] == 'N')
- {
- switch (field[5])
- {
- case 'A':
- sys->modemtype |= ISDNA;
- case 'B':
- sys->modemtype |= ISDNB;
- case 'C':
- sys->modemtype |= ISDNC;
- }
- }
- else
- if (field[1] == 'V' && field[2] == '1' && field[3] == '1' && field[4] == '0')
- {
- switch (field[5])
- {
- case 'L':
- sys->modemtype |= ISDNA;
- case 'H':
- sys->modemtype |= ISDNB;
- }
- }
- else
- if (field[1] == 'V' && field[2] == '3')
- {
- if (field[3] == '2' && field[4] == 'T')
- sys->modemtype |= (V32T|V32B|V32|MNP);
- else if (field[3] == '4')
- sys->modemtype |= (V34|V32B|V32|MNP);
- }
- else
- if (field[1] == 'X' && field[2] == '7')
- sys->modemtype |= ISDNC;
-
- }
- else
- {
- if (field[1] == 'S' && field[2] == 'D' && field[3] == 'N')
- {
- switch (field[4])
- {
- case 'A':
- sys->modemtype |= ISDNA;
- case 'B':
- sys->modemtype |= ISDNB;
- case 'C':
- sys->modemtype |= ISDNC;
- }
- }
- else
- if (field[0] == 'V' && field[1] == '1' && field[2] == '1' && field[3] == '0')
- {
- switch (field[4])
- {
- case 'L':
- sys->modemtype |= ISDNA;
- case 'H':
- sys->modemtype |= ISDNB;
- }
- }
- }
- }
- }
- }
-
- return(OK);
- }
-